﻿using FluentValidation.Results;
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Micro.Extensions.DDD.Events;

namespace Micro.Extensions.DDD.Commands
{
    /// <summary>
    /// 抽象命令基类
    /// </summary>
    public abstract class Command : Message, IRequest<bool>
    {
        /// <summary>
        /// 时间戳
        /// </summary>
        public DateTimeOffset Timestamp { get; private set; }
        /// <summary>
        /// 验证结果，需要引用FluentValidation
        /// </summary>
        public ValidationResult ValidationResult { get; set; }

        protected Command()
        {
            Timestamp = DateTimeOffset.Now;
        }

        /// <summary>
        /// 定义抽象方法，是否有效
        /// </summary>
        /// <returns></returns>
        public abstract bool IsValid();
    }
}
